home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.text;
-
- import java.util.Hashtable;
- import javax.swing.event.DocumentEvent;
- import javax.swing.event.DocumentEvent.EventType;
- import javax.swing.undo.CannotRedoException;
- import javax.swing.undo.CannotUndoException;
- import javax.swing.undo.CompoundEdit;
- import javax.swing.undo.UndoableEdit;
-
- public class AbstractDocument$DefaultDocumentEvent extends CompoundEdit implements DocumentEvent {
- // $FF: synthetic field
- private final AbstractDocument this$0;
- private int offset;
- private int length;
- private Hashtable changeLookup;
- private DocumentEvent.EventType type;
-
- public AbstractDocument$DefaultDocumentEvent(AbstractDocument var1, int var2, int var3, DocumentEvent.EventType var4) {
- this.this$0 = var1;
- this.offset = var2;
- this.length = var3;
- this.type = var4;
- }
-
- // $FF: synthetic method
- static DocumentEvent.EventType access$0(AbstractDocument$DefaultDocumentEvent var0) {
- return var0.type;
- }
-
- public boolean addEdit(UndoableEdit var1) {
- if (this.changeLookup == null && super.edits.size() > 10) {
- this.changeLookup = new Hashtable();
- int var2 = super.edits.size();
-
- for(int var3 = 0; var3 < var2; ++var3) {
- Object var4 = super.edits.elementAt(var3);
- if (var4 instanceof DocumentEvent.ElementChange) {
- DocumentEvent.ElementChange var5 = (DocumentEvent.ElementChange)var4;
- this.changeLookup.put(var5.getElement(), var5);
- }
- }
- }
-
- if (this.changeLookup != null && var1 instanceof DocumentEvent.ElementChange) {
- DocumentEvent.ElementChange var6 = (DocumentEvent.ElementChange)var1;
- this.changeLookup.put(var6.getElement(), var6);
- }
-
- return super.addEdit(var1);
- }
-
- public DocumentEvent.ElementChange getChange(Element var1) {
- if (this.changeLookup != null) {
- return (DocumentEvent.ElementChange)this.changeLookup.get(var1);
- } else {
- int var2 = super.edits.size();
-
- for(int var3 = 0; var3 < var2; ++var3) {
- Object var4 = super.edits.elementAt(var3);
- if (var4 instanceof DocumentEvent.ElementChange) {
- DocumentEvent.ElementChange var5 = (DocumentEvent.ElementChange)var4;
- if (var5.getElement() == var1) {
- return var5;
- }
- }
- }
-
- return null;
- }
- }
-
- public Document getDocument() {
- return this.this$0;
- }
-
- public int getLength() {
- return this.length;
- }
-
- public int getOffset() {
- return this.offset;
- }
-
- public String getPresentationName() {
- DocumentEvent.EventType var1 = this.getType();
- if (var1 == EventType.INSERT) {
- return "addition";
- } else {
- return var1 == EventType.REMOVE ? "deletion" : "style change";
- }
- }
-
- public String getRedoPresentationName() {
- return "Redo " + this.getPresentationName();
- }
-
- public DocumentEvent.EventType getType() {
- return this.type;
- }
-
- public String getUndoPresentationName() {
- return "Undo " + this.getPresentationName();
- }
-
- public boolean isSignificant() {
- return true;
- }
-
- public void redo() throws CannotRedoException {
- this.this$0.writeLock();
-
- try {
- super.redo();
- if (this.type == EventType.INSERT) {
- this.this$0.fireInsertUpdate(this);
- } else if (this.type == EventType.REMOVE) {
- this.this$0.fireRemoveUpdate(this);
- } else {
- this.this$0.fireChangedUpdate(this);
- }
- } finally {
- this.this$0.writeUnlock();
- }
-
- }
-
- public String toString() {
- return super.edits.toString();
- }
-
- public void undo() throws CannotUndoException {
- this.this$0.writeLock();
-
- try {
- super.undo();
- if (this.type == EventType.REMOVE) {
- this.this$0.fireInsertUpdate(this);
- } else if (this.type == EventType.INSERT) {
- this.this$0.fireRemoveUpdate(this);
- } else {
- this.this$0.fireChangedUpdate(this);
- }
- } finally {
- this.this$0.writeUnlock();
- }
-
- }
- }
-